<template>
	<div class="home">
		<Header ref="header"></Header>
		<Search :keywords="keywords" @setName='setname'></Search>
		<Banner></banner>
		<Card @saveInfo="saveInfo" @getSpecial="getSpecial" @getInfo="getInfo" @getpaotui="getpaotui" @getConvenient="getConvenient" @getBuy="getBuy"></Card>
		<Administration ref="zhengfu" v-if="siteType==2"></Administration>
		<Task ref="task" v-if="siteType==2"></Task>
		<lifeServer ref="lifeServer" v-if="siteType==2"></lifeServer>
		<notice-server ref="notice-server" v-if="siteType==2"></notice-server>
		<Convenient ref="Convenient" v-if="siteType==2"></Convenient>
		<Server></Server>
		<NewsBox></NewsBox>
		<Experience ref="jianwen"></Experience>
		<Experience ref="fazhi"></Experience>
		<Experience ref="gongyi"></Experience>
		<NewsList ref="news"></NewsList>
		<Interaction ref="diaocha"></Interaction>
		<div class="report">
			<a href='http://www.12377.cn/'>向平台举报</a>
		</div>
		<van-row gutter="4" style="width: 96%;margin: 0 auto;">
			<van-col span="8" v-for="i in advList" :key="i.id" @click="topage(i.url)">
				<img v-lazy="$base_serve+i.image" class="advimg" alt="">
			</van-col>
		</van-row>
		<div class="adv-box">
			<div class="header">
				<span>友情链接</span>
			</div>
			<div class="content">
				<van-grid :gutter="10" :column-num="3" style="padding-left: 0;">
					<img v-lazy="value.image" alt="" v-for="value in AD" :key="value.id" class="adimage" @click="topage(value.url)">
				</van-grid>
			</div>
		</div>

	</div>
</template>

<script>
	import Header from "@/components/header.vue"
	import Search from "@/components/home/search.vue"
	import Banner from "@/components/home/banner.vue"
	import Card from "@/components/home/card.vue"
	import Server from "@/components/home/server.vue"
	import NewsBox from "@/components/home/newsbox.vue"
	import Experience from "@/components/home/experiences.vue"
	import NewsList from "@/components/home/newslist.vue"
	import Interaction from "@/components/home/Interaction.vue"
	import Administration from "@/components/home/administration.vue"
	import Task from "@/components/home/task.vue"
	import lifeServer from "@/components/home/lifeServer.vue"
	import NoticeServer from "@/components/home/NoticeServer.vue"
	import Convenient from "@/components/home/Convenient.vue"
	import adv from "@/assets/img/jiaozi.png"
	export default {
		name: "Home",
		components: {
			Header,
			Search,
			Banner,
			Card,
			Server,
			NewsBox,
			Experience,
			NewsList,
			Interaction,
			Administration,
			Task,
			lifeServer,
			NoticeServer,
			Convenient
		},
		data() {
			return {
				adv: adv,
				keywords: '',
				AD: [],
				advList: [],
				siteType:1
			}
		},
		mounted() {
			
			if(this.$localStorage.get("siteType") == null){
				this.$localStorage.set("siteType",1)
			}
			this.siteType = this.$localStorage.get("siteType")
			this.$api.home.friendsLink().then(res => {
				// 执行某些操作
				if (res.code == 1) {
					this.AD = res.data
				}

			})
			let bannerdata = {
				category_id: 41
			}
			this.$api.home.bannerAds(bannerdata).then(res => {
				// 执行某些操作
				if (res.code == 1) {
					this.advList = res.data
				}

			})


		},
		methods: {
			setname(name) {
				this.$refs.header.setName(name)
			},
			saveInfo(item) {
				let that = this
				item.forEach(index => {
					if (index.name == "家园见闻") {
						that.$refs.jianwen.getList(index)
					}
					if (index.name == "法治道德") {
						that.$refs.fazhi.getList(index)
					}
					if (index.name == "法制道德") {
						that.$refs.fazhi.getList(index)
					}
					if (index.name == "公益帮助") {
						that.$refs.gongyi.getList(index)
					}
					if (index.name == "家园调查") {
						that.$refs.diaocha.getList(index)
					}
				})
			},
			getSpecial(item) {
				this.$refs.news.getList(item)
			},
			topage(url) {
				window.location.href = url
			},
			getInfo(item){
				this.$refs.zhengfu.getData(item)
			},
			getpaotui(item){
				this.$refs.task.getData(item)
			},
			getConvenient(item){
				this.$refs.Convenient.getData(item)
			},
			getBuy(item){
				this.$refs.Convenient.getbuy(item)
			}
		}


	}
</script>

<style scoped lang="less">
	.home {
		margin-top: 2.08rem;
	}

	.report {
		width: 95%;
		// height:8.56rem;
		background: #FE7700;
		box-shadow: 0rem 0rem 0rem 0rem rgba(206, 206, 206, 0.29);
		margin: 0.5rem auto;
		padding: 0.88rem 0.78rem;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 4.69rem;

		span {
			width: 5.19rem;
			height: 1.31rem;
			border: 1px solid rgba(255, 255, 255, 1);
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 0.75rem;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
		}

		a {
			width: 5.19rem;
			height: 1.31rem;
			border: 1px solid rgba(255, 255, 255, 1);
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 0.75rem;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
		}
	}

	.advimg {
		width: 100%;
	}

	.adv-box {
		width: 95%;
		// height:8.56rem;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0rem 0rem 0rem 0rem rgba(206, 206, 206, 0.29);
		border-radius: 0.2rem;
		margin: 0.5rem auto;
		padding: 0.88rem 0.78rem;

		.header {
			span {
				width: 5.56rem;
				height: 2rem;
				background: rgba(254, 119, 0, 1);
				font-size: 0.81rem;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: rgba(255, 255, 255, 1);
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}

		.content {
			margin-top: 10px;

			.adimage {
				width: 30%;
				margin-right: 2%;
			}
		}
	}
</style>
<style>
	.adv-box .van-grid-item__content {
		padding: 16px 4px;
	}

	.adv-box .van-grid-item:nth-child(3n) {
		padding-right: 0 !important;
	}
</style>
